package com.liuchuanzheng.lcz_study_demo.hook;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;

public class HCallback implements Handler.Callback {

    public  static final  int LAUNCH_ACIVITY = 100;

    Handler mHandler;

    public HCallback(Handler handler){
        mHandler = handler;
    }

    @Override
    public boolean handleMessage(Message msg) {
        if(msg.what == LAUNCH_ACIVITY){

            Object r = msg.obj;

            try {
                Intent intent = (Intent) FieldUtil.getField(r.getClass(),r,"intent");

                Intent target = intent.getParcelableExtra(HookHelper.TARGET_INTENT);

                intent.setComponent(target.getComponent());

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

        mHandler.handleMessage(msg);

        return true;
    }
}

